//
//  NSString+Common.m
//  通讯录LV2.0
//
//  Created by dllo on 16/8/6.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "NSString+Common.h"

@implementation NSString (Common)

#pragma mark - 将字符串转化为拼音，并首字母大写返回
- (NSString *)CapitalOfName
{
    CFStringRef hanzi = (__bridge CFStringRef)self;
    CFMutableStringRef string = CFStringCreateMutableCopy(NULL, 0, hanzi);
    CFStringTransform(string, NULL, kCFStringTransformMandarinLatin, NO);
    CFStringTransform(string, NULL, kCFStringTransformStripDiacritics, NO);
    NSString *pinyin = (NSString *)CFBridgingRelease(string);
    pinyin = [pinyin stringByReplacingOccurrencesOfString:@" " withString:@""];
    NSString *capitalStr = [[pinyin substringToIndex:1] capitalizedString];
    return capitalStr;
}

//是否是纯字母

-(BOOL)PureLetters{
    
    for(int i=0; i<self.length; i++){
        
        unichar c=[self characterAtIndex:i];
        
        if((c<'A'||c>'Z')&&(c<'a'||c>'z'))
            
            return NO;
    }
    
    return YES;
    
}

@end
